﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MB.Orm.DB;
using MB.RuleBase.Common;
using Model;
using Public.DataAccess;
using System.Data;

namespace Business.Service
{
    public class BDCJDOrder
    {
        public BDCJDOrder() { }

        public List<DCJDOrder> GetDCJDOrderList(int pageIndex, int pageSize, out int total, params object[] parValues)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<DCJDOrder> list = PagedDatabaseExcuteByXmlHelper.NewInstance.GetPagedObjectsByXml3<DCJDOrder>
                                                ("DCOrder", "GetDCJDOrderList", pageIndex, pageSize, out total, parValues);
                return list;
            }
        }
        public List<DCJDOrderDetail> GetGetDCJDOrderListDetailByORDERCODE(string ORDERCODE)
        {
            try
            {
                using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
                {
                    List<DCJDOrderDetail> list = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<DCJDOrderDetail>
                                                    ("DCOrder", "GetGetDCJDOrderListDetailByORDERCODE", ORDERCODE);
                    return list;
                }
            }
            catch (Exception ex)
            {
                MB.Util.TraceEx.Write(ex.Message);
                return null;
            }
        }

        public List<DCJDOrder> GetDCJDOrderListByOrderid(string orderid)
        {
            try
            {
                using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
                {
                    List<DCJDOrder> list = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<DCJDOrder>
                                                    ("DCOrder", "GetDCJDOrderListByOrderid", orderid);
                    return list;
                }
            }
            catch (Exception ex)
            {
                MB.Util.TraceEx.Write(ex.Message);
                return null;
            }
        }

        public List<DCJDOrder> GetDCJDOrderListForPrint(string OrderCode, string checkTimeS, string checkTimeE, string Status, string disGs, string disStatus)
        {
            using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
            {
                List<DCJDOrder> list = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<DCJDOrder>("DCOrder", "GetDCJDOrderListForPrint"
                       , OrderCode, checkTimeS, checkTimeE, Status, disGs, disStatus);
                return list;
            }
        }
        public List<DCJDOrderDetail> GetGetDCJDOrderListDetailForPrint(string OrderCode, string checkTimeS, string checkTimeE, string Status, string disGs, string disStatus)
        {
            try
            {
                using (var DbScope = new OperationDatabaseScope(new OperationDatabaseContext("NewWeb")))
                {
                    List<DCJDOrderDetail> list = DatabaseExcuteByXmlHelper.NewInstance.GetObjectsByXml<DCJDOrderDetail>
                                                    ("DCOrder", "GetGetDCJDOrderListDetailForPrint", OrderCode, checkTimeS, checkTimeE, Status, disGs, disStatus);
                    return list;
                }
            }
            catch (Exception ex)
            {
                MB.Util.TraceEx.Write(ex.Message);
                return null;
            }
        }


        /// <summary>
        /// 更新配送状态
        /// </summary>
        /// <param name="dCwarehouse"></param>
        /// <returns></returns>
        public int UpdateDCJDorderDISstatus(DCJDOrder dCJDOrder)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<DCJDOrder>("DCOrder", "UpdateDCJDorderDISstatus", dCJDOrder);
        }


        /// <summary>
        /// 更新配送公司
        /// </summary>
        /// <param name="dCwarehouse"></param>
        /// <returns></returns>
        public int UpdateDCJDorderDISType(DCJDOrder dCJDOrder)
        {
            return DatabaseExcuteByXmlHelper.NewInstance.ExecuteNonQueryByEntity<DCJDOrder>("DCOrder", "UpdateDCJDorderDISType", dCJDOrder);
        }
    }
}
